﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Abhiruchi_Phase1;

namespace Abhiruchi_Phase1.BAL_DAL.ORG_DAL
{
    class LocationMasterDAL
    {
        public static string CS = App.ConnectionString;
        public static DataTable GetORGLocationMaster()
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_LocationMaster";
            mycom.CommandType = CommandType.StoredProcedure;                       
            mycom.Parameters.AddWithValue("@Ptype", 1);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }
        public static DataTable GetORGLocationMasterInsert(string LocationName, string Address, string LocationIncharge, string ContactNumber, int IsActive)            
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_LocationMaster";
            mycom.CommandType = CommandType.StoredProcedure;            
            mycom.Parameters.AddWithValue("@LocationName",LocationName);
            mycom.Parameters.AddWithValue("@Address",Address);
            mycom.Parameters.AddWithValue("@LocationIncharge", LocationIncharge);
            mycom.Parameters.AddWithValue("@ContactNumber",ContactNumber);
            mycom.Parameters.AddWithValue("@IsActive",IsActive);
            mycom.Parameters.AddWithValue("@Ptype",2);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }

        public static DataTable GetLocationMasterUpdate(int LocationID,string LocationName, string Address, string LocationIncharge, string ContactNumber, int IsActive)
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_LocationMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@LocationID", LocationID);
            mycom.Parameters.AddWithValue("@LocationName", LocationName);
            mycom.Parameters.AddWithValue("@Address", Address);
            mycom.Parameters.AddWithValue("@LocationIncharge", LocationIncharge);
            mycom.Parameters.AddWithValue("@ContactNumber", ContactNumber);
            mycom.Parameters.AddWithValue("@IsActive", IsActive);
            mycom.Parameters.AddWithValue("@Ptype", 3);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }

        public static DataTable GetORGLoactionUpdate(string LocationID)
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_LocationMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@LocationID", LocationID);
            mycom.Parameters.AddWithValue("@Ptype", 4);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }

        public static DataTable GetORGLoactionENames()
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_LocationMaster";
            mycom.CommandType = CommandType.StoredProcedure;            
            mycom.Parameters.AddWithValue("@Ptype", 5);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }

        public static DataTable GetORGLoactionInchargeName()
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_LocationMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@Ptype", 6);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }

        public static DataTable GetORGLoactionId()
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_LocationMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@Ptype", 7);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }

        public static DataTable GetORGLoactionNameCompare(int LocationID, string LocationName)
        {
            SqlConnection mycon = new SqlConnection(CS);
            SqlCommand mycom = new SqlCommand();
            mycom.Connection = mycon;
            mycom.CommandText = "SP_ORG_Get_Set_LocationMaster";
            mycom.CommandType = CommandType.StoredProcedure;
            mycom.Parameters.AddWithValue("@LocationID", LocationID); 
            mycom.Parameters.AddWithValue("@LocationName", LocationName);            
            mycom.Parameters.AddWithValue("@Ptype", 8);
            SqlDataAdapter myadp = new SqlDataAdapter(mycom);
            DataTable mydt = new DataTable();
            myadp.Fill(mydt);
            return mydt;
        }
    }
}
